**************************************
* immediately after release
**************************************

clear

* load data for the first PACT after release from facility
use Residential CAR_CPACT_1stFS.dta

* define pact date for this pact score
rename pactdte pactdte1


* build the indicators, factors and sumary variables
 do Factors_ReSTAT
 
* build the specific noncognitive variables
 do Noncog_Detail_ReSTAT

* standardize and rename the variables
foreach x in gangz mental_health  skills_r agg_r att_r noncog_r agg implsv attitude socskill future {
	rename `x' `x'_final
	egen `x'_final2=std(`x'_final)
	}
	
* make file for merge
keep pactdte1 gangz_final2 mental_health_final2 skills_r_final2  agg_r_final2  att_r_final2 noncog_r_final2 ///
	 agg_final2 implsv_final2 attitude_final2 socskill_final2 future_final2 ///
	RELEASE_YR ID_VAR FILE_TYPE CAR_CPACT 
save "CPACT_1_ReSTAT.dta", replace 


**************************************
* 8 months out
**************************************

clear

* load data for the PACT taken 8 months after release from facility
use Residential CAR_CPACT_FS8mos.dta


* build the indicators, factors and sumary variables
 do Factors_ReSTAT
 
* build the specific noncognitive variables
 do Noncog_Detail_ReSTAT


* define pact date for this pact score 
rename pactdte pactdte8

* standardize and rename the variables
foreach x in  skills_r  agg_r  att_r noncog_r  agg implsv attitude ///
    socskill future gangz {
	rename `x' `x'_8
	egen `x'_82=std(`x'_8)
	}
	
*  rename the dummy variables 
foreach x in gangz drug alc dropout mental_health drug_curr alc_curr school_enroll school_conduct school_attend school_perform wantjob schoolmis badgrades truancy hasjob gradGED {
gen `x'_8= `x'
	}
	
* make file for merge
keep RELEASE_YR ID_VAR FILE_TYPE CAR_CPACT skills_r_82 agg_r_82  att_r_82 noncog_r_82  agg_82 implsv_82 attitude_82 socskill_82 future_82 gangz_82
save CPACT_8_ReSTAT.dta, replace 

clear



